package com.example.cms.Payments;


import java.time.LocalDateTime;

public class Payment {
    private Integer paymentId;
    private Integer appointmentId;
    private String paymentNo;
    private Double amount;
    private String paymentMethod;
    private String paymentStatus;
    private String transactionNo;
    private LocalDateTime paymentTime;
    private String payerName;
    private String payerIdCard;
    private String remarks;
    private LocalDateTime createTime;

    // 构造器
    public Payment() {
        this.createTime = LocalDateTime.now();
        this.paymentStatus = "PENDING";
    }

    public Payment(Integer appointmentId, Double amount, String paymentMethod) {
        this();
        this.appointmentId = appointmentId;
        this.amount = amount;
        this.paymentMethod = paymentMethod;
        this.paymentNo = generatePaymentNo();
    }

    // Getter 和 Setter 方法
    public Integer getPaymentId() {
        return paymentId;
    }

    public void setPaymentId(Integer paymentId) {
        this.paymentId = paymentId;
    }

    public Integer getAppointmentId() {
        return appointmentId;
    }

    public void setAppointmentId(Integer appointmentId) {
        this.appointmentId = appointmentId;
    }

    public String getPaymentNo() {
        return paymentNo;
    }

    public void setPaymentNo(String paymentNo) {
        this.paymentNo = paymentNo;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public String getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(String paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public String getPaymentStatus() {
        return paymentStatus;
    }

    public void setPaymentStatus(String paymentStatus) {
        this.paymentStatus = paymentStatus;
        if ("SUCCESS".equals(paymentStatus)) {
            this.paymentTime = LocalDateTime.now();
        }
    }

    public String getTransactionNo() {
        return transactionNo;
    }

    public void setTransactionNo(String transactionNo) {
        this.transactionNo = transactionNo;
    }

    public LocalDateTime getPaymentTime() {
        return paymentTime;
    }

    public void setPaymentTime(LocalDateTime paymentTime) {
        this.paymentTime = paymentTime;
    }

    public String getPayerName() {
        return payerName;
    }

    public void setPayerName(String payerName) {
        this.payerName = payerName;
    }

    public String getPayerIdCard() {
        return payerIdCard;
    }

    public void setPayerIdCard(String payerIdCard) {
        this.payerIdCard = payerIdCard;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    private String generatePaymentNo() {
        return "PAY" + System.currentTimeMillis();
    }

    @Override
    public String toString() {
        return "Payment{" +
                "paymentId=" + paymentId +
                ", paymentNo='" + paymentNo + '\'' +
                ", amount=" + amount +
                ", paymentMethod='" + paymentMethod + '\'' +
                ", paymentStatus='" + paymentStatus + '\'' +
                ", paymentTime=" + paymentTime +
                '}';
    }
}